package com.dgut.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dgut.common.model.entity.Goods;
import com.dgut.common.service.GoodService;
import com.dgut.common.util.SystemJsonResponse;
import com.dgut.service.GoodsService;

/**
 * @author huangyujia <huangyujia@kuaishou.com>
 * Created on 2024-06-18
 */
@Service
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    private GoodService goodService;

    @Override
    public SystemJsonResponse getGoodsList() {
        List<Goods> goodList = goodService.getList();
        return SystemJsonResponse.success(goodList);
    }

    @Override
    public SystemJsonResponse addGoods(Goods goods) {
        goods.setCreateTime(System.currentTimeMillis());
        goods.setUpdateTime(System.currentTimeMillis());
        goodService.save(goods);
        return SystemJsonResponse.success();
    }

    @Override
    public SystemJsonResponse deleteGoods(String id) {
        goodService.deleteById(id);
        return SystemJsonResponse.success();
    }

    @Override
    public SystemJsonResponse updateGoods(Goods goods) {
        goods.setUpdateTime(System.currentTimeMillis());
        goodService.updateById(goods);
        return null;
    }

}
